package com.syq.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.syq.mapper.DtsRegionMapper;
import com.syq.pojo.DtsRegion;
import com.syq.service.DtsRegionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;

/**
 * @ClassName: DtsRegionServiceImpl
 * @Description: TODO
 * @Create by: syq
 * @Date: 2022/7/26 8:50
 */
@Transactional
@Service
public class DtsRegionServiceImpl implements DtsRegionService {

    @Autowired
    private DtsRegionMapper dtsRegionMapper;

    @Override
    public IPage<DtsRegion> findByPage(Integer page, Integer limit, Integer code, String name) {
        return dtsRegionMapper.selectPage(new Page<>(page,limit),
                new QueryWrapper<DtsRegion>()
                        .like(!StringUtils.isEmpty(name),"name",name)
                        .eq(!StringUtils.isEmpty(code),"code",code));
    }
}
